package com.jinzhu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jinzhu.mapper.CarouselMapper;
import com.jinzhu.pojo.Carousel;
import com.jinzhu.service.CarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * 首页轮播图
 * jinzhu
 */
@Service
public class CarouselServiceImpl  implements CarouselService {
    @Autowired
    CarouselMapper carouselMapper;


    /**
     * Propagation.SUPPORTS 如果当前存在事务，则加入该事务；如果当前没有事务，则以非事务的方式继续运行。
     * 查询所有轮播图
     * @author jinzhu
     * @param isShow
     */
    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<Carousel> queryAll(Integer isShow) {
        List<Carousel> carousels = carouselMapper.selectList(new QueryWrapper<Carousel>()
                .lambda()
                .eq(Carousel::getIsShow, isShow));
        return carousels;
    }
}
